<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <!--移动端的预览设置，用于适配移动端-->
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="stylesheet" th:href="@{/Semantic-UI-CSS-master/semantic.min.css}">
    <link rel="stylesheet" th:href="@{/css/myblog.css}">
    <link rel="stylesheet" th:href="@{/lib/editor.md-master/css/editormd.min.css}">
    <title>后台管理</title>


</head>
<body>
<!--导航-->
<div th:replace="~{admin/manage::adminNav}"></div>

<!--二级导航-->
<div class="ui menu attached inverted ">
    <div class="ui container">
        <a href="/admin/blog-input" class="active item">发布</a>
        <a href="/admin/blogs" class="item">列表</a>
    </div>
</div>
<!--中间内容-->
<div class="m-container-small m-padded-tb-big">
    <div class="ui container">
        <form action="/admin/blogAdd" method="post" target="_blank" class="ui form">
            <!--用此种方式可以把提交方式变成put，原理就是SpringBoot默认维护了一个WebMvcAutoConfiguration，其中如果有_method就改变请求方式
             不过SpringBoot项目得在配置中开启，默认是关闭的 spring.mvc.hiddenmethod.filter.enabled=true-->
            <!--            <input type="hidden" name="_method" th:value="${method}"/>-->
            <!--            <input type="hidden" name="id" th:value="${blog?.getId()}">-->
            <div class="field required">
                <div class="ui right labeled action input ">
                    <input type="text" name="title" placeholder="标题" >
                    <div class="ui selection dropdown orange basic label compact">
                        <!--                      发布博客的类型标识  -->
                        <input type="hidden" name="property" th:value="原创">

                        <i class="ui dropdown icon"></i>
                        <div class="text">原创</div>
                        <div class="ui menu">
                            <div class="item" data-value="1">原创</div>
                            <div class="item" data-value="2">转载</div>
                            <div class="item" data-value="3">翻译</div>
                        </div>
                    </div>
                </div>

            </div>
            <div class="field required">
                <input type="text" name="summary" class="ui input" placeholder="摘要" >
            </div>
<!--            <input id="content"   type="hidden">-->
            <div class="field">
                <div id="md-content" style="z-index: 1 !important;">
                    <textarea name="content" placeholder="博客内容"  ></textarea>
                    [TOC]
                    #### Disabled options

                    - TeX (Based on KaTeX);
                    - Emoji;
                    - Task lists;
                    - HTML tags decode;
                    - Flowchart and Sequence Diagram;

                    #### Editor.md directory

                    editor.md/
                    lib/
                    css/
                    scss/
                    tests/
                    fonts/
                    images/
                    plugins/
                    examples/
                    languages/
                    editormd.js
                    ...

                    ```html
                </div>
            </div>

            <div class="two fields ">
                <!--分类-->
                <div class="ui left labeled action input field">
                    <label class="ui compact teal basic label">分类</label>
                    <div class="ui selection dropdown fluid">
                        <input type="hidden" name="columnId" >
                        <i class="ui dropdown icon"></i>
                        <div class="default text">分类</div>
                        <div class="menu">
                            <div class="item" th:each="c,iterStat:${cList}" th:data-value="${c?.getId()}"
                                 th:text="${c?.getName()}"></div>
                        </div>
                    </div>
                </div>
                <!--标签-->
                <div class="ui left labeled action input field ">
                    <label class="ui compact teal basic label">标签</label>
                    <div class="ui selection multiple search dropdown fluid">
                        <input type="hidden" name="tags" th:value="${blog?.getTags()}">
                        <i class="ui dropdown icon"></i>
                        <div class="default text">标签</div>
                        <div class="menu">
                            <div class="item" th:each="tag,iterStat:${tList}" th:data-value="${tag?.getId()}"
                                 th:text="${tag?.getName()}"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="filed">
                <div class="ui left labeled input fluid">
                    <label class="ui teal basic label">首图</label>
                    <input type="text" name="blogImg" placeholder="首图引用地址" >
                </div>
            </div>

            <div class="inline fields m-padded-tb-small">
                <div class="field">
                    <div class="ui checkbox">
                        <input type="checkbox" id="recommend" name="recommendState" value="1" class="hidden"
                               >
                        <label for="recommend">推荐&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
                    </div>
                    <div class="ui checkbox">
                        <input type="checkbox" id="shareInfo" name="reprintState" value="1" class="hidden"
                             >
                        <label for="shareInfo">转载声明&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
                    </div>
                    <div class="ui checkbox">
                        <input type="checkbox" id="appreciation" name="admireState" value="1" class="hidden"
                               >
                        <label for="appreciation">赞赏&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
                    </div>
                    <div class="ui checkbox">
                        <input type="checkbox" id="comment" name="commentState" value="1" class="hidden"
                               >
                        <label for="comment">留言</label>
                    </div>
                </div>
            </div>


            <div class="ui right aligned container">
                <button type="button" class="ui button" onclick="window.history.go(-1)">返回</button>
                <button type="submit" class="ui button teal" name="blogState" value="0">保存</button>
                <button type="submit" class="ui button red" name="blogState" value="1">发布</button>
            </div>
            <div class="ui error message"></div>
        </form>
    </div>
</div>
<br>
<br>
<!--底部footer-->
<div th:replace="~{index::footer}"></div>


<script th:src="@{/js/jquery-3.5.1.min.js}"></script>
<script th:src="@{/Semantic-UI-CSS-master/semantic.min.js}"></script>
<script th:src="@{/lib/editor.md-master/editormd.min.js}"></script>

<script type="text/javascript">
    $("#b1").click(function () {
        $(".m-item").toggleClass("m-mobile-hide");
    });
    $('#payButton').popup({
        popup: $('.popup.payQR'),
        on: 'click',
        position: 'bottom center'
    });
    $('.ui.dropdown').dropdown({
        on: 'hover'
    })
    // https://semantic-ui.com/behaviors/form.html
    $('.ui.form').form({
        fields: {
            title: {
                identifier: 'title',
                rules: [{
                    type: 'empty',
                    prompt: '标题：请输入博客标题'
                }]
            },
            summary: {
                identifier: 'summary',
                rules: [{
                    type: 'empty',
                    prompt: '摘要：请输入博客摘要'
                }]
            },
            type: {
                identifier: 'type',
                rules: [{
                    type: 'empty',
                    prompt: '分类：请选择博客分类'
                }]
            },
            tags: {
                identifier: 'tags',
                rules: [{
                    type: 'empty',
                    prompt: '标签：请选择博客标签'
                }]
            },
            pictureUrl: {
                identifier: 'pictureUrl',
                rules: [{
                    type: 'empty',
                    prompt: '首图地址：请输入首图地址'
                }]
            },
        }
    })
    // https://github.com/pandao/editor.md
    // https://pandao.github.io/editor.md/examples/simple.html
    var contentEditor;
    $(function () {
        contentEditor = editormd({
            id: "md-content",
            width: "100%",
            height: 640,
            syncScrolling: "single",
            path: "/lib/editor.md-master/lib/"
        });

        /*
        // or
        testEditor = editormd({
            id      : "test-editormd",
            width   : "90%",
            height  : 640,
            path    : "../lib/"
        });
        */
    });
</script>
</body>
</html>